<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>系统设置</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" type="text/css" href="css/main.css" />
  <link rel="stylesheet" type="text/css" href="../mobile/js/layer/css/layui.css" />
  <link rel="stylesheet" type="text/css" href="css/style.css"/>
  <script src="./js/jquery-1.9.1.js"></script>
  <script src="../mobile/js/layer/layui.js"></script>
  <script src="./js/common.js"></script>
  <style type="text/css">
  .layui-inline{
      width: 48% !important;
  }
  .layui-form-label{
      background: #F2F2F2 !important;
  }
  </style>
</head>
<body>
<div class="setting_meun">
	<ul class="setting_meunul">
		<a href="setting_information.html"><li class="active">基本设置</li><a/>
		<a href="setting_message.html"><li>短信设置</li></a>
    <a href="setting_template.html"><li>模板设置</li></a>
	</ul>
	<div class="clear"></div>
</div>
<div style="margin: -30px 20px 20px 20px;">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
  <legend>系统设置</legend>
</fieldset>
<blockquote class="layui-elem-quote">
	 <button class="layui-btn btns" onclick="x_admin_show('添加系统设置','./setting_add.html',600,450)"><i class="layui-icon" style="color: #fff">&#xe608;</i> 添加</button>
</blockquote>
<form method="post" class="layui-form layui-form-pane">
  <div class="layui-form-item">
    <label class="layui-form-label">网站名称</label>
    <div class="layui-input-block">
      <input type="text" name="title" autocomplete="off" placeholder="请输入网站名称" class="layui-input" id="title">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">网站域名</label>
    <div class="layui-input-block">
      <input type="text" name="dns" autocomplete="off" placeholder="请输入网站名称" class="layui-input" id="dns">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">网站状态</label>
    <div class="layui-input-block">
      <input type="checkbox" name="open" lay-skin="switch" id="open" lay-text="开启|关闭">
    </div>
  </div>
  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">网站描述</label>
    <div class="layui-input-block">
      <textarea name="titledes" placeholder="请输入描述内容" class="layui-textarea" autocomplete="off" id="titledes"></textarea>
    </div>
  </div>
  <div class="layui-upload">
  <button type="button" class="layui-btn btns" id="logoBtn">
    <i class="layui-icon" style="color: #fff">&#xe67c;</i>上传图片
  </button>
  <div class="layui-upload-list">
    <img class="layui-upload-img" id="demo1" width="150">
    <p id="demoText"></p>
  </div>
  </div>   
  <div class="layui-form-item layui-form-text">
    <div class="layui-inline">
      <label class="layui-form-label">一级代理分佣比例</label>
      <div class="layui-input-block">
         <input type="text" name="agent1" autocomplete="off" placeholder="请输入一级代理分佣比例" class="layui-input" id="agent1">
      </div>
    </div>
    <div class="layui-inline">
      <label class="layui-form-label">二级代理分佣比例</label>
      <div class="layui-input-block">
         <input type="text" name="agent2" autocomplete="off" placeholder="请输入二级代理分佣比例" class="layui-input" id="agent2">
      </div>
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-inline">
      <label class="layui-form-label">阿里云id</label>
      <div class="layui-input-block">
         <input type="text" name="accessKeyId" autocomplete="off" placeholder="请输入阿里云id" class="layui-input" id="accessKeyId">
      </div>
    </div>
    <div class="layui-inline">
      <label class="layui-form-label">阿里云secret</label>
      <div class="layui-input-block">
         <input type="text" name="accessKeySecret" autocomplete="off" placeholder="请输入阿里云secret" class="layui-input" id="accessKeySecret">
      </div>
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-inline">
      <label class="layui-form-label">短信签名</label>
      <div class="layui-input-block">
       <input type="text" name="signName" autocomplete="off" placeholder="请输入短信签名" class="layui-input" id="signName">
      </div>
    </div>
    <div class="layui-inline">
      <label class="layui-form-label">短信模板</label>
      <div class="layui-input-block">
         <input type="text" name="templateCode" autocomplete="off" placeholder="请输入短信模板" class="layui-input" id="templateCode">
      </div>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">wifi设备充值</label>
    <div class="layui-input-block">
      <input type="text" name="device_recharge_url" autocomplete="off" placeholder="请输入wifi设备充值" class="layui-input" id="device_recharge_url">
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-inline">
      <label class="layui-form-label">微信appid</label>
      <div class="layui-input-block">
       <input type="text" name="appid" autocomplete="off" placeholder="请输入微信appid" class="layui-input" id="appid">
      </div>
    </div>
    <div class="layui-inline">
      <label class="layui-form-label">微信secret</label>
      <div class="layui-input-block">
         <input type="text" name="secret" autocomplete="off" placeholder="请输入微信secret" class="layui-input" id="secret">
      </div>
    </div>
  </div>
  <div class="layui-form-item layui-form-text">
    <div class="layui-inline" style="width: 30% !important;">
      <label class="layui-form-label">wifi设备总信息查询</label>
      <div class="layui-input-block">
       <input type="text" name="get_device_info_url" autocomplete="off" placeholder="请输入wifi设备总信息查询" class="layui-input" id="get_device_info_url">
      </div>
    </div>
    <div class="layui-inline" style="width: 30% !important;">
      <label class="layui-form-label">wifi充值需要的UID</label>
      <div class="layui-input-block">
         <input type="text" name="uid" autocomplete="off" placeholder="请输入wifi充值需要的UID" class="layui-input" id="uid">
      </div>
    </div>
    <div class="layui-inline" style="width: 30% !important;">
      <label class="layui-form-label">wifi充值需要的signkey</label>
      <div class="layui-input-block">
         <input type="text" name="signkey" autocomplete="off" placeholder="请输入wifi充值需要的signkey" class="layui-input" id="signkey">
      </div>
    </div>
  </div>
  <div class="layui-form-item layui-form-text">
    <div class="layui-inline" style="width: 23% !important;">
      <label class="layui-form-label">七牛</label>
      <div class="layui-input-block">
       <input type="text" name="accessKey" autocomplete="off" placeholder="请输入七牛" class="layui-input" id="accessKey">
      </div>
    </div>
    <div class="layui-inline" style="width: 23% !important;">
      <label class="layui-form-label">七牛</label>
      <div class="layui-input-block">
         <input type="text" name="secretKey" autocomplete="off" placeholder="请输入七牛" class="layui-input" id="secretKey">
      </div>
    </div>
    <div class="layui-inline" style="width: 23% !important;">
      <label class="layui-form-label">七牛</label>
      <div class="layui-input-block">
         <input type="text" name="bucket" autocomplete="off" placeholder="请输入七牛" class="layui-input" id="bucket">
      </div>
    </div>
    <div class="layui-inline" style="width: 23% !important;">
      <label class="layui-form-label">七牛</label>
      <div class="layui-input-block">
         <input type="text" name="qiniuurl" autocomplete="off" placeholder="请输入七牛" class="layui-input" id="qiniuurl">
      </div>
    </div>
  </div>
  <div class="layui-form-item layui-form-text">
    <div class="layui-inline" style="width: 30% !important;">
      <label class="layui-form-label">wifi设备查询套餐</label>
      <div class="layui-input-block">
       <input type="text" name="taocan_to_device_url" autocomplete="off" placeholder="请输入wifi设备查询套餐" class="layui-input" id="taocan_to_device_url">
      </div>
    </div>
    <div class="layui-inline" style="width: 30% !important;">
      <label class="layui-form-label">wifi设备实名认证接口</label>
      <div class="layui-input-block">
         <input type="text" name="shiming_to_device_url" autocomplete="off" placeholder="请输入wifi设备实名认证接口" class="layui-input" id="shiming_to_device_url">
      </div>
    </div>
    <div class="layui-inline" style="width: 30% !important;">
      <label class="layui-form-label">wifi设备查询</label>
      <div class="layui-input-block">
         <input type="text" name="device_auth" autocomplete="off" placeholder="请输入wifi设备查询" class="layui-input" id="device_auth">
      </div>
    </div>
  </div>
  <div class="layui-form-item layui-form-text">
     <div class="layui-inline" style="width: 30% !important;">
      <label class="layui-form-label">阿里云物联套餐productKey</label>
      <div class="layui-input-block">
         <input type="text" name="productKey" autocomplete="off" placeholder="请输入阿里云物联套餐productKey" class="layui-input" id="productKey">
      </div>
    </div>
    <div class="layui-inline" style="width: 30% !important;">
      <label class="layui-form-label">对接友方查询洗衣机状态接口</label>
      <div class="layui-input-block">
         <input type="text" name="select_device_url" autocomplete="off" placeholder="请输入对接友方查询洗衣机状态接口" class="layui-input" id="select_device_url">
      </div>
    </div>
    <div class="layui-inline" style="width: 30% !important;">
      <label class="layui-form-label">查询洗衣机状态接口解析</label>
      <div class="layui-input-block">
         <input type="text" name="select_xiyiji_url" autocomplete="off" placeholder="请输入查询洗衣机状态接口解析" class="layui-input" id="select_xiyiji_url">
      </div>
    </div>
  </div>
  <div class="layui-form-item">
    <button type="submit" class="layui-btn btns" lay-submit lay-filter="config">确定</button>
    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
  </div>
</form>
</div>          
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
layui.use(['form','layer','upload'], function(){
  var form = layui.form
  ,layer = layui.layer
  ,upload = layui.upload
  ,$ = layui.jquery;

  //系统设置信息显示
  var urls = url + "/admin/config/index";
  $.ajax({
    type: 'get',
    dataType: "json",
    url: urls,
    success: function(msg){
    	if(msg.code == 1){	
    	   $("#title").val(msg['data']['title']);
         $("#dns").val(msg['data']['dns']);
         if(msg['data']['open'] == 1){
            $("#open").attr('checked','checked');
            $(".layui-unselect").addClass('layui-form-onswitch');
            $(".layui-unselect em").text('开启');
         }
    	   $("#titledes").val(msg['data']['titledes']);
    	   $('#demo1').attr('src', '../'+msg['data']['logo']); //图片链接（base64）
         $("#agent1").val(msg['data']['agent1']);
         $("#agent2").val(msg['data']['agent2']);
         $("#accessKeyId").val(msg['data']['accessKeyId']);
         $("#accessKeySecret").val(msg['data']['accessKeySecret']);
         $("#signName").val(msg['data']['signName']);
         $("#templateCode").val(msg['data']['templateCode']);
         $("#device_recharge_url").val(msg['data']['device_recharge_url']);
         $("#appid").val(msg['data']['appid']);
         $("#secret").val(msg['data']['secret']);
         $("#get_device_info_url").val(msg['data']['get_device_info_url']);
         $("#uid").val(msg['data']['uid']);
         $("#signkey").val(msg['data']['signkey']);
         $("#accessKey").val(msg['data']['accessKey']);
         $("#secretKey").val(msg['data']['secretKey']);
         $("#bucket").val(msg['data']['bucket']);
         $("#qiniuurl").val(msg['data']['qiniuurl']);
         $("#taocan_to_device_url").val(msg['data']['taocan_to_device_url']);
         $("#shiming_to_device_url").val(msg['data']['shiming_to_device_url']);
         $("#device_auth").val(msg['data']['device_auth']);
         $("#productKey").val(msg['data']['productKey']);
         $("#select_device_url").val(msg['data']['select_device_url']);
         $("#select_xiyiji_url").val(msg['data']['select_xiyiji_url']);
    	}else{
         layer.alert("你还未设置系统设置", {icon: 5});
    	}
    },
    error:function(){
       layer.alert("请求失败", {icon: 5});
    }
  });

  var urls = url + "/admin/config/upload";
  //普通图片上传
  var uploadInst = upload.render({
  	elem: '#logoBtn'
  	,url: urls
  	,data: urls
    ,before: function(obj){
      //预读本地文件示例，不支持ie8
      obj.preview(function(index, file, result){
        $('#demo1').attr('src', result); //图片链接（base64）
      });
    }
  	,done: function(msg){
  		//上传成功
  		if(msg.code == 1){
          layer.alert(msg.infomsg, {icon: 6});     
  		}else{  
          layer.alert(msg.infomsg, {icon: 5});     
  		}
  	}
  	,error:function(){
	     //演示失败状态，并实现重传
	      var demoText = $('#demoText');
	      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
	      demoText.find('.demo-reload').on('click', function(){
	        uploadInst.upload();
	  });
  	}
  });


  //修改配置信息
  form.on('submit(config)', function(data){
  	var urls = url + "/admin/config/update";
    $.post(urls,data.field,function(msg){
       var msg = JSON.parse(msg);
        if(msg.code == 1){
            layer.alert(msg.infomsg, {icon: 6});
        }else{
            layer.alert(msg.infomsg, {icon: 5});
        }
    });
    return false;
  }); 
});
</script>
</body>
</html>